package com.itcast.manager2.C_service;

import com.itcast.manager2.D_dao.StudentDao;
import com.itcast.manager2.E_domain.Student;

import java.util.ArrayList;

public class StudentService {

    private StudentDao sd = new StudentDao();

    public void addStudent(Student s) {
        sd.addStudent(s);
    }

    public boolean isExists(String id) {
        ArrayList<Student> list = sd.getAllStudent();
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            if (id.equals(stu.getId())) {
                return true;
            }
        }
        return false;
    }

    public void deleteStudent(String id) {
        sd.deleteStudent(id);
    }

    public ArrayList<Student> findAllStudent() {
        ArrayList<Student> AllStudent = sd.getAllStudent();
        return AllStudent;
    }

    public void updateStdent(Student stu) {
        sd.updateStdent(stu);
    }
}
